package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.bean.RoleBean;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;
/**
 * @Title: IRoleMapper
 * @Package: com.project.mapper
 * @Description:
 * @Author: Liang-Xie
 */
@SuppressWarnings("all")
@Mapper
public interface IRoleMapper extends BaseMapper<RoleBean> {

    List<RoleBean> findByUserId(Integer userId);

    @Select("SELECT * FROM t_role;")
    @ResultMap("roleMap")
    List<RoleBean> findAll();

    @Delete("DELETE FROM t_role_grade WHERE fk_roleId=#{roleId};"+
            "DELETE FROM t_user_role WHERE fk_roleId=#{roleId};"+
            "DELETE FROM t_role WHERE pk_roleId=#{roleId}")
    void delRole(Integer roleId);

    @Delete("delete from t_role_grade where fk_roleId=#{roleId};")
    void delRoleGrade(Integer roleId);

}
